<%--
  Created by IntelliJ IDEA.
  User: 赵千陆
  Date: 2020/10/9
  Time: 10:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>&lt;jsp:useBean&gt;demo</title>
</head>
<body>
<h2>
    &lt;jsp:useBean&gt;demo action demo
</h2>
<%--create user1--%>
<jsp:useBean id="user1" class="lzy.mbh.User"/>
<jsp:useBean id="user2" class="lzy.mbh.User" scope="session"/>
<%--set and get value--%>
<%
    user1.setName("Tom");
    user1.setSex("Male");
    user1.setSpeciality("Computer science");

    user2.setName("Bob");
    user2.setSex("Female");
    user2.setSpeciality("Network enginnerring");

    // print user info
    out.println("user1 info:" + user1.toString() + "<br>");
    out.println("user2 info:" + user2   .toString() + "<br>");
%>
<jsp:useBean id="user3" class="lzy.mbh.User" scope="session"/>
<jsp:setProperty name="user3" property="name" value="John"/>
<jsp:setProperty name="user3" property="sex" value="Female"/>
<jsp:setProperty name="user3" property="speciality" value="Software enginnering"/>

<%--使用jsp:getProperty来获取对象属性值--%>
user3 info
User:{
<jsp:getProperty name="user3" property="name"/>,
<jsp:getProperty name="user3" property="sex"/>,
<jsp:getProperty name="user3" property="speciality"/>
}

</body>
</html>
